<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${me.daoInfo.packageStr}.${me.daoInfo.className}">
	<sql id="baseColumn">

	</sql>

	<sql id="basesql">
		<!-- select t.*, a.sn as carrierCode from ( -->
		select
		<include refid="baseColumn"></include>
		from ${tableName} t
		<!-- left join sys_organization a on t.carrierId = a.id -->
		where 1=1
    <#noparse>
		<!--<if test="carrierId !=null and carrierId!=''">
			and t.carrierId = #{carrierId}
		</if>-->
    </#noparse>
	</sql>

	<select id="queryBySql" resultType="${me.entityInfo.className }Dto" parameterType="java.util.Map">
		<#noparse>
		select t.* from (
		<include refid="basesql"></include>
		) t where 1=1

		<if test="order !=null and order!=''">
			ORDER BY ${order}
		</if>
		LIMIT #{offset},#{limit}
		</#noparse>
	</select>

	<select id="countBySql" resultType="int" parameterType="java.util.Map">
		select count(1) from (
		<include refid="basesql"></include>
		) t where 1=1
    <#noparse>
		<!-- <if test="sn !=null and sn!=''">
		 and t.sn like concat('%',#{sn},'%')
		 </if> -->
    </#noparse>
	</select>

	<select id="loadById" resultType="${me.entityInfo.className }Dto">
    <#noparse>
		select t.* from (
		<include refid="basesql"></include><!--复用 -->
		) t
		WHERE id=#{id}
    </#noparse>
	</select>

	<delete id="delete" parameterType="java.util.Map">
		DELETE FROM ${tableName}
		WHERE id IN
	<#noparse>
		<foreach collection="id" index="index" item="item" open="("
				 separator="," close=")">
		#{item}
		</foreach>
	</#noparse>
	</delete>
</mapper>